﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Compilex.Automata;
using Compilex.BaseLibrary;

namespace Compilex.Lexer.Automata
{
    public class PositiveIntegerDFA : DFA
    {
        public PositiveIntegerDFA()
        {
            this.StartState = BuildAutomaton();
        }

        private DFAState BuildAutomaton()
        {
            DFAState startState = new DFAState("q0");
            DFAState acceptState = new DFAState("q1", true);

            startState.AddTransition(
                new PredicateTransitionRule<DFAState>(StringUtils.IsDigit, acceptState));
            acceptState.AddTransition(
                 new PredicateTransitionRule<DFAState>(StringUtils.IsDigit, acceptState));

            return startState;
        }
    }
}
